package cn.xtits.xtf.common.web;

import org.aspectj.weaver.loadtime.Aj;

import java.io.Serializable;

/**
 * Created by Administrator on 2016/1/26.
 */
public class AjaxResult implements Serializable {

    public static final Integer SERVER_ERROR = -500;
    private Integer code;
    private Integer bizCode;
    private String msg;
    private Object data;
    private Boolean sNulls = true;

    public void setBizCode(Integer bizCode) {
        this.bizCode = bizCode;
    }

    public static AjaxResult GetResult() {
        return GetResult(ResultCode.SUCCESS, null, null,false);
    }

    public static AjaxResult GetResult(ResultCode code) {
        return GetResult(code, null, null,false);
    }

    public static AjaxResult GetResult(ResultCode code, String msg) {
        return new AjaxResult(code,msg,null,false);
    }

    public static AjaxResult GetResult(ResultCode code, String msg, Object data) {
        return new AjaxResult(code,msg,data,false);
    }

    public  static AjaxResult GetResult(Object data){
        return GetResult(ResultCode.SUCCESS,"",data,false);
    }

    public static AjaxResult GetResult(Object data, boolean serializeNulls) {
        return GetResult(ResultCode.SUCCESS,"",data,serializeNulls);
    }

    public static AjaxResult GetResult(ResultCode code, String msg, Object data, boolean serializeNulls) {
        return new AjaxResult(code,msg,data,serializeNulls);
    }

    private AjaxResult() {
    }

    private AjaxResult(ResultCode code, String msg, Object data, boolean serializeNulls) {
        if (null == data) {
            data = "";
        }
        if (null == msg) {
            msg = "";
        }
        this.sNulls = serializeNulls;
        this.code = code.code;
        this.msg = msg;
        this.data = data;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(ResultCode code) {
        this.code = code.code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public Boolean getsNulls() {
        return sNulls;
    }


}


